import { reactive } from 'vue';

export default function importConfig() {
  const data = [
    {
      MA001: 'MA001',
      TD001: 'TD001',
      TD002: 'TD002',
      TD004: 'TD004',
      TD005: 'TD005',
      TD007: 'TD007',
      TD008: 'TD008',
      TD009: 'TD009',
      TD010: 'TD010',
      TD011: 'TD011',
      TD012: 'TD012',
      TD014: 'TD014',
      TD018: 'TD018',
      TD016: 'TD016',
    },
  ];

  const base = reactive<any>({
    size: 'medium',
    columns: [],
    searchConfig: null,
    config: [],
    pagination: {
      defaultPageSize: 10,
      total: data.length, //总条数
      current: 1,
      pageSize: 10,
      showTotal: true,
      showPageSize: true,
      pageSizeOptions: [10, 20, 30, 40, 50],
    },
    loading: true,
    editVisible: false,
  });

  const opArticleNumber = () => {
    // router.push('/numberConfiguration')
  };

  /**
   * @exports searchConfig 搜索栏配置表
   */
  const searchConfig = [
    {
      label: '公司名称',
      key: 'COMPANY',
      placeholder: '请输入公司名称',
      value: null,
    },
    {
      label: '创建人',
      key: 'CREATOR',
      placeholder: '请输入创建人',
      value: null,
    },
    {
      label: '供应商ID',
      key: 'MA001',
      placeholder: '请输入供应商ID',
      value: null,
    },
    {
      label: '供应商名称',
      key: 'MA003',
      placeholder: '请输入供应商名称',
      value: null,
    },
    {
      label: '负责人',
      key: 'MA011',
      placeholder: '请输入供应商负责人',
      value: null,
    },
    {
      label: '负责人号码',
      key: 'MA011',
      placeholder: '请输入供应商负责人的手机号',
      value: null,
    },
  ];

  const columnsConfig = [
    {
      title: '供应商',
      dataIndex: 'MA001',
      checked: true,
    },
    {
      title: '采购单别',
      dataIndex: 'TD001',
      checked: true,
    },
    {
      title: '采购单号',
      dataIndex: 'TD002',
      checked: true,
    },
    {
      title: '品号',
      dataIndex: 'TD004',
      checked: true,
    },
    {
      title: '品名',
      dataIndex: 'TD005',
      checked: true,
    },
    {
      title: '交货仓库',
      dataIndex: 'TD007',
      checked: true,
    },
    {
      title: '采购数量',
      dataIndex: 'TD008',
      checked: true,
    },
    {
      title: '单位',
      dataIndex: 'TD009',
      checked: true,
    },
    {
      title: '采购单价',
      dataIndex: 'TD010',
      checked: true,
    },

    {
      title: '采购金额',
      dataIndex: 'TD011',
      checked: true,
    },
    {
      title: '预交货日',
      dataIndex: 'TD012',
      checked: true,
    },

    {
      title: '备注',
      dataIndex: 'TD014',
      checked: true,
    },
    {
      title: '审核状态',
      dataIndex: 'TD018',
      checked: true,
    },
    {
      title: '订单状态',
      dataIndex: 'TD016',
      checked: true,
    },
    {
      title: '操作',
      slotName: 'option',
      checked: true,
    },
  ];

  const config = ['add', 'Download', 'derive'];
  const collection = reactive([
    { label: '公司名称', value: '', placeholder: '请输入公司名称', isInput: true },
    { label: '创建人', value: '', placeholder: '请输入创建人', isSelect: true },
    { label: '供应商 ID', value: '', placeholder: '请输入供应商 ID', isInput: true },
    { label: '供应商名称', value: '', placeholder: '请输入供应商名称', isInput: true },
    { label: '负责人', value: '', placeholder: '请输入负责人', isInput: true },
    { label: '负责人号码', value: '', placeholder: '请输入负责人号码', isInput: true },
  ]);

  /**
   * @exports init 初始化
   */
  const init = () => {
    base.searchConfig = searchConfig;
    base.columns = columnsConfig;
    base.config = config;
    base.loading = false;
  };

  /**
   * @exports tapDate 触发搜索
   * @param param
   */
  const tapDate = (param) => {
    // console.log(param, '==>tapDate')
    // console.log(getInitParam(queryDataFilter(param)), '==>tapDate')
  };

  /**
   * @exports handlePageChange 页码变化时
   */
  const handlePageChange = (page: number) => {
    base.pagination.current = page;
    init();
  };
  const handlePageSizeChange = (pageSize: number) => {
    base.pagination.pageSize = pageSize;
    init();
  };

  const edit = () => {
    base.editVisible = true;
  };

  return {
    base,
    collection,
    data,
    opArticleNumber,
    init,
    tapDate,
    handlePageChange,
    handlePageSizeChange,
    edit,
  };
}
